home *** CD-ROM | disk | FTP | other *** search
/ Quick PC 61 / Quick PC 61.iso / I386 / WMS.CAB / glossary.js < prev    next >
Encoding:
JavaScript  |  2003-02-21  |  5.6 KB  |  164 lines

  1. /* Copyright (c) Microsoft Corporation.  All rights reserved. */
  2. /*
  3.     Glossary.js ver 1.00.4 - 6:48 PM 7/24/2001
  4. */
  5. /* Start Localize */
  6. var L_EntryNotFound        = "<SPAN STYLE='color:red; font-weight:bold'>Definition not found.</SPAN>";
  7. var L_PopUpTitle        = "Glossary Term";
  8. /* End Localize */
  9. var bIE                    = 0;
  10. var bNN                    = 0;
  11. var glbPlatformCode        = 0;
  12. var glbBrowserCode        = 0;
  13. var glbVersion            = 0;
  14. var glbSubVersion        = 0;
  15. var uav                 = window.navigator.appVersion;
  16. var uan                 = window.navigator.appName;
  17. if (parseInt(uan.indexOf("Internet Explorer")) >= 0){
  18.     glbBrowserCode = 10;
  19.     glbVersion = parseInt(uav.substring(uav.indexOf("MSIE ") + 5,uav.indexOf("MSIE ") + 7));
  20.     glbSubVersion = parseInt(uav.substring(uav.indexOf("MSIE ") + 7,uav.indexOf("MSIE ") + 9));
  21.     bIE = 1;
  22. }
  23. if (parseInt(uan.indexOf("Netscape")) >= 0){
  24.     glbBrowserCode = 20;
  25.     glbVersion = parseInt(uav.substring(0,4));
  26.     glbSubVersion = parseInt(uav.substring(2,4));
  27.     bNN = 1;
  28. }
  29. if (uav.lastIndexOf("Win") >= 0){
  30.     glbPlatformCode = 10;
  31.     if ((uav.lastIndexOf("Windows 95") >= 0) || (uav.lastIndexOf("Win95") >= 0)){
  32.     glbPlatformCode = 11;
  33.     }
  34.     if ((uav.lastIndexOf("Windows 98") >= 0) || (uav.lastIndexOf("Win98") >= 0)){
  35.     glbPlatformCode = 12;
  36.     }
  37.     if ((uav.lastIndexOf("Windows NT") >= 0) || (uav.lastIndexOf("WinNT") >= 0)){
  38.     glbPlatformCode = 20;
  39.     }    
  40. }
  41. else
  42. {
  43.     if (uav.lastIndexOf("Mac") >= 0){
  44.         glbPlatformCode = 30;    
  45.     }
  46. }
  47. var oPopup             = 0;
  48. var sDBGlossary     = "../dbGlossary.csv";
  49. var bDataSetComplete = 0;
  50. function InitializePopUp()
  51. {
  52.     if (bIE && ( ( glbVersion >=5 && glbSubVersion >= 5) || (glbVersion >= 6) ) ){
  53.         setPopUp();
  54.         enablePopUp();
  55.     }
  56.     else{
  57.         disablePopUp();
  58.     }
  59. }
  60. function setPopUp(){
  61.     oPopup = window.createPopup();
  62. }
  63. function enablePopUp(){
  64.     var sStyle = "";
  65.     sStyle += '<STYLE> #PopUp{cursor: hand; color: green; text-decoration: underline;}</STYLE>\n';
  66.     sStyle += '<STYLE> #idGlossary{cursor: hand; color: green; text-decoration: underline;}</STYLE>\n';
  67.     var sOnClickEvent = "";
  68.     sOnClickEvent += '<SCR' + 'IPT LANGUAGE="JScript" FOR="PopUp" EVENT="onclick">';
  69.     sOnClickEvent += '    getTermDefinition(this); return false';
  70.     sOnClickEvent += '</SCR' + 'IPT>\n' ;
  71.     sOnClickEvent += '<SCR' + 'IPT LANGUAGE="JScript" FOR="idGlossary" EVENT="onclick">';
  72.     sOnClickEvent += '    getTermDefinition(this); return false';
  73.     sOnClickEvent += '</SCR' + 'IPT>\n' ;
  74.     var sOnMouseOverEvent = "";
  75.     sOnMouseOverEvent += '<SCR' + 'IPT LANGUAGE="JScript" FOR="PopUp" EVENT="onmouseover">';
  76.     sOnMouseOverEvent += '    this.title = "' + L_PopUpTitle + '";'
  77.     sOnMouseOverEvent += '</SCR' + 'IPT>\n' ;
  78.     sOnMouseOverEvent += '<SCR' + 'IPT LANGUAGE="JScript" FOR="idGlossary" EVENT="onmouseover">';
  79.     sOnMouseOverEvent += '    this.title = "' + L_PopUpTitle + '";'
  80.     sOnMouseOverEvent += '</SCR' + 'IPT>\n' ;
  81.     var sObj = "";
  82.     sObj += '<OBJECT ID="dbGlossary" CLASSID="clsid:333C7BC4-460F-11D0-BC04-0080C7055A83" STYLE="height: 0; width: 0; display:none; position:absolute;" ondatasetcomplete="bDataSetComplete = 1">';
  83.     sObj += '    <PARAM NAME="DataURL" VALUE="' + sDBGlossary + '">';
  84.     sObj += '    <PARAM NAME="UseHeader" VALUE="True">';
  85.     sObj += '    <PARAM NAME="TextQualifier" VALUE="|">';
  86.     sObj += '</OBJECT>\n';
  87.     var sDynLen = "";
  88.     sDynLen = "<DIV ID='idDynamicLength' STYLE='width:400; height:10; overflow:scroll; visibility:hidden; position:absolute;'></DIV></NOBR>";
  89.     window.self.document.write(sStyle);
  90.     window.self.document.write(sOnClickEvent);
  91.     window.self.document.write(sOnMouseOverEvent);
  92.     window.self.document.write(sObj);
  93.     window.self.document.write(sDynLen);
  94. }
  95. function disablePopUp(){
  96.     var sStyle = "";
  97.     sStyle += '<STYLE> #PopUp{color: black; text-decoration: none; cursor="default"}</STYLE>';
  98.     var sStyle1 = "";
  99.     sStyle1 += '<STYLE> #idGlossary{color: black; text-decoration: none; cursor="default"}</STYLE>';
  100.     window.self.document.write(sStyle);
  101.     var sOnClickEvent = "";
  102.     sOnClickEvent += '<SCR' + 'IPT LANGUAGE="JScript" FOR="PopUp" EVENT="onclick">';
  103.     sOnClickEvent += '    return false;';
  104.     sOnClickEvent += '</SCR' + 'IPT>\n' ;
  105.     window.self.document.write(sStyle);
  106.     window.self.document.write(sOnClickEvent);
  107. }
  108. function getTermDefinition(oObj){
  109.     var ar, sRid;
  110.     if (oObj.href){
  111.         ar = oObj.href.split("#");
  112.         ar.length > 1 ? sRid = ar[1] : sRid = "";
  113.     }
  114.     else{
  115.         sRid = oObj.RID;
  116.     }
  117.     var Gls = getDefinition(sRid);
  118.     if (Gls.found){
  119.         idDynamicLength.innerHTML = Gls.definition;
  120.         Gls.definition = idDynamicLength.innerText;
  121.     }
  122.     var sDef = "<DIV STYLE='width:100%; height:100%; font-family:verdana; font-size: 11; padding: .25em; background-color: #BBDEFC; border-color:#000000 ; border-width:1; border-style:solid;'>";
  123.     sDef += formatTerm(Gls.term);
  124.     sDef += formatDefinition(Gls.definition);
  125.     sDef += "</DIV>\n";
  126.     
  127.     idDynamicLength.innerHTML = sDef;
  128.     var nWidth = idDynamicLength.scrollWidth + 4;
  129.     var nHeight = idDynamicLength.scrollHeight + 4;
  130.     oPopup.document.body.innerHTML = sDef;
  131.     oPopup.show(0, -nHeight, nWidth, nHeight, oObj);
  132. }
  133. function getDefinition(sKey){
  134.     var oRecordSet = dbGlossary.recordset;
  135.     oRecordSet.MoveFirst();
  136.     var def = new DEF();
  137.     for(var i = 0; i < oRecordSet.RecordCount; i++)
  138.     {
  139.         if(sKey.toLowerCase() == oRecordSet.fields.item('rid').value.toLowerCase())
  140.         {
  141.             def.term = oRecordSet.fields.item('key').value;
  142.             def.definition = oRecordSet.fields.item('def').value;
  143.             def.found = 1;
  144.             return def;
  145.         }
  146.         oRecordSet.MoveNext();
  147.     }
  148.     def.term = sKey;
  149.     def.definition = L_EntryNotFound;
  150.     return def;
  151. }
  152. function DEF(){
  153.     this.term = "";
  154.     this.definition = "";
  155.     this.found = 0;
  156. }
  157. function formatTerm(sStr){
  158.         return ("<B>" + sStr + "</B><BR>");
  159. }
  160. function formatDefinition(sStr){
  161.         return (" " + sStr + " ");
  162. }
  163. InitializePopUp();
  164.